#!/usr/bin/env python3
from Crypto.Cipher import AES
import markdown, sys, os, re, hashlib
if len(sys.argv) <= 2:
	sys.exit("no enough arguments")
infile = open(sys.argv[1])
outfile = open(os.path.splitext(sys.argv[1])[0] + '.html', 'w')
outfile.write("<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"utf-8\">\n")
if len(sys.argv) >= 3 and re.match(".*.css", sys.argv[3]):
	outfile.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + sys.argv[3] + "\">\n")
outfile.write("""</head>
<body>
<h1>这篇文章被加密了……</h1>
<input type="button" value="输入密码" onclick='foobar()' />
<script src="https://raw.fastgit.org/emn178/js-md5/master/build/md5.min.js">
<script src="https://raw.fastgit.org/brix/crypto-js/develop/src/aes.js">
<script type="text/javascript">
function foobar() {
foo = "
""" + hashlib.md5(bytes(sys.argv[2], 'utf-8')).hexdigest() + '"\nbar="' +)
#+ markdown.markdown(infile.read(), extensions = ["markdown.extensions.extra"]) + "\n<br /><br />\n<small><small>最后修改于" + time.ctime(os.path.getctime(sys.argv[1])) + "</small></small>\n</body>\n</html>")
# 
